package com.rlyy.grpc.component;

import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;

/**
 */
@javax.annotation.Generated(
    value = "by gRPC proto compiler (version 1.33.1)",
    comments = "Source: handler.proto")
public final class GrpcProcessGrpc {

  private GrpcProcessGrpc() {}

  public static final String SERVICE_NAME = "grpc.GrpcProcess";

  // Static method descriptors that strictly reflect the proto.
  private static volatile io.grpc.MethodDescriptor<RpcRequest,
      RpcResponse> getHandlerMethod;

  @io.grpc.stub.annotations.RpcMethod(
      fullMethodName = SERVICE_NAME + '/' + "handler",
      requestType = RpcRequest.class,
      responseType = RpcResponse.class,
      methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
  public static io.grpc.MethodDescriptor<RpcRequest,
      RpcResponse> getHandlerMethod() {
    io.grpc.MethodDescriptor<RpcRequest, RpcResponse> getHandlerMethod;
    if ((getHandlerMethod = GrpcProcessGrpc.getHandlerMethod) == null) {
      synchronized (GrpcProcessGrpc.class) {
        if ((getHandlerMethod = GrpcProcessGrpc.getHandlerMethod) == null) {
          GrpcProcessGrpc.getHandlerMethod = getHandlerMethod =
              io.grpc.MethodDescriptor.<RpcRequest, RpcResponse>newBuilder()
              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
              .setFullMethodName(generateFullMethodName(SERVICE_NAME, "handler"))
              .setSampledToLocalTracing(true)
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  RpcRequest.getDefaultInstance()))
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  RpcResponse.getDefaultInstance()))
              .setSchemaDescriptor(new GrpcProcessMethodDescriptorSupplier("handler"))
              .build();
        }
      }
    }
    return getHandlerMethod;
  }

  /**
   * Creates a new async stub that supports all call types for the service
   */
  public static GrpcProcessStub newStub(io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<GrpcProcessStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<GrpcProcessStub>() {
        @Override
        public GrpcProcessStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new GrpcProcessStub(channel, callOptions);
        }
      };
    return GrpcProcessStub.newStub(factory, channel);
  }

  /**
   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
   */
  public static GrpcProcessBlockingStub newBlockingStub(
      io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<GrpcProcessBlockingStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<GrpcProcessBlockingStub>() {
        @Override
        public GrpcProcessBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new GrpcProcessBlockingStub(channel, callOptions);
        }
      };
    return GrpcProcessBlockingStub.newStub(factory, channel);
  }

  /**
   * Creates a new ListenableFuture-style stub that supports unary calls on the service
   */
  public static GrpcProcessFutureStub newFutureStub(
      io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<GrpcProcessFutureStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<GrpcProcessFutureStub>() {
        @Override
        public GrpcProcessFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new GrpcProcessFutureStub(channel, callOptions);
        }
      };
    return GrpcProcessFutureStub.newStub(factory, channel);
  }

  /**
   */
  public static abstract class GrpcProcessImplBase implements io.grpc.BindableService {

    /**
     */
    public void handler(RpcRequest request,
                        io.grpc.stub.StreamObserver<RpcResponse> responseObserver) {
      asyncUnimplementedUnaryCall(getHandlerMethod(), responseObserver);
    }

    @Override public final io.grpc.ServerServiceDefinition bindService() {
      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
          .addMethod(
            getHandlerMethod(),
            asyncUnaryCall(
              new MethodHandlers<
                RpcRequest,
                RpcResponse>(
                  this, METHODID_HANDLER)))
          .build();
    }
  }

  /**
   */
  public static final class GrpcProcessStub extends io.grpc.stub.AbstractAsyncStub<GrpcProcessStub> {
    private GrpcProcessStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected GrpcProcessStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new GrpcProcessStub(channel, callOptions);
    }

    /**
     */
    public void handler(RpcRequest request,
                        io.grpc.stub.StreamObserver<RpcResponse> responseObserver) {
      asyncUnaryCall(
          getChannel().newCall(getHandlerMethod(), getCallOptions()), request, responseObserver);
    }
  }

  /**
   */
  public static final class GrpcProcessBlockingStub extends io.grpc.stub.AbstractBlockingStub<GrpcProcessBlockingStub> {
    private GrpcProcessBlockingStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected GrpcProcessBlockingStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new GrpcProcessBlockingStub(channel, callOptions);
    }

    /**
     */
    public RpcResponse handler(RpcRequest request) {
      return blockingUnaryCall(
          getChannel(), getHandlerMethod(), getCallOptions(), request);
    }
  }

  /**
   */
  public static final class GrpcProcessFutureStub extends io.grpc.stub.AbstractFutureStub<GrpcProcessFutureStub> {
    private GrpcProcessFutureStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected GrpcProcessFutureStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new GrpcProcessFutureStub(channel, callOptions);
    }

    /**
     */
    public com.google.common.util.concurrent.ListenableFuture<RpcResponse> handler(
        RpcRequest request) {
      return futureUnaryCall(
          getChannel().newCall(getHandlerMethod(), getCallOptions()), request);
    }
  }

  private static final int METHODID_HANDLER = 0;

  private static final class MethodHandlers<Req, Resp> implements
      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
    private final GrpcProcessImplBase serviceImpl;
    private final int methodId;

    MethodHandlers(GrpcProcessImplBase serviceImpl, int methodId) {
      this.serviceImpl = serviceImpl;
      this.methodId = methodId;
    }

    @Override
    @SuppressWarnings("unchecked")
    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        case METHODID_HANDLER:
          serviceImpl.handler((RpcRequest) request,
              (io.grpc.stub.StreamObserver<RpcResponse>) responseObserver);
          break;
        default:
          throw new AssertionError();
      }
    }

    @Override
    @SuppressWarnings("unchecked")
    public io.grpc.stub.StreamObserver<Req> invoke(
        io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        default:
          throw new AssertionError();
      }
    }
  }

  private static abstract class GrpcProcessBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
    GrpcProcessBaseDescriptorSupplier() {}

    @Override
    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
      return GrpcHandler.getDescriptor();
    }

    @Override
    public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
      return getFileDescriptor().findServiceByName("GrpcProcess");
    }
  }

  private static final class GrpcProcessFileDescriptorSupplier
      extends GrpcProcessBaseDescriptorSupplier {
    GrpcProcessFileDescriptorSupplier() {}
  }

  private static final class GrpcProcessMethodDescriptorSupplier
      extends GrpcProcessBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
    private final String methodName;

    GrpcProcessMethodDescriptorSupplier(String methodName) {
      this.methodName = methodName;
    }

    @Override
    public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
      return getServiceDescriptor().findMethodByName(methodName);
    }
  }

  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;

  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
    io.grpc.ServiceDescriptor result = serviceDescriptor;
    if (result == null) {
      synchronized (GrpcProcessGrpc.class) {
        result = serviceDescriptor;
        if (result == null) {
          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
              .setSchemaDescriptor(new GrpcProcessFileDescriptorSupplier())
              .addMethod(getHandlerMethod())
              .build();
        }
      }
    }
    return result;
  }
}
